package com.atde._04_structural_design_patterns.facade;


/**
 * @BelongsProject: hsp_java_design_mode
 * @BelongsPackage: com.atde._04_structural_design_patterns.facade
 * @Author: Del
 * @CreateTime: 2025-06-23  09:11
 * @Description: 外观模式 --- 爆米花
 * @Version: 1.0
 */
public class Popcorn {

    // 私有化构造器
    private Popcorn () {}

    // 私有实例变量用volatile关键字进行修饰
    private static volatile Popcorn instance;

    public static Popcorn getInstance() {
        if (instance == null) {
            synchronized (Popcorn.class) {
                if (instance == null) {
                    instance =  new Popcorn();
                }
            }
        }
        return instance;
    }

    public void on() {
        System.out.println("打开爆米花机......");
    }

    public void off() {
        System.out.println("关闭爆米花机......");
    }

    public void pop() {
        System.out.println("弹出爆米花......");
    }
}
